import java.util.*;

/**
 * @author LKQ
 * @date 2022/5/21 15:00
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.numSteps( "1111");
    }
    public int numSteps(String s) {
        int n = s.length();
        char[] S = s.toCharArray();
        char[] ch = new char[n + 1];
        ch[0] = '0';
        System.arraycopy(S, 0, ch, 1, n);
        int cnt = 0, len = n + 1;
        while (true) {
            if (ch[n] == '1') {
                int j = n;
                while (j >= 0 && ch[j] == '1') {
                    j--;
                }
                ch[j] = '1';
                Arrays.fill(ch, j + 1, len, '0');
            }else if (ch[n] == '0'){
                for (int j = n; j >= 1; j--) {
                    ch[j] = ch[j - 1];
                }
                ch[0] = '0';
            }
            cnt++;
            boolean finish = true;
            for (int i = 0; i < n; i++) {
                if (ch[i] != '0') {
                    finish = false;
                    break;
                }
            }
            if (finish) {
                break;
            }
        }
        return cnt;
    }

}
